package com.dragon.rabbitmq.service;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.dragon.rabbitmq.SharedDataMqProvideApiCore;
import com.dragon.rabbitmq.dto.EdcSharedDataDTO;
import com.fintech.common.util.PropertiesUtils;
import com.marvels.common.utils.MarvelsLogUtil;

import net.sf.json.JSONObject;

@Service
public class SharedDataMqProvideImplCore implements SharedDataMqProvideApiCore{

	@Autowired
	private AmqpTemplate amqpTemplate;
	
	@Value("${loanid.prefix}")
	private String prefix;
	@Override
	public void synSharedDataUpdate(EdcSharedDataDTO synStatus) throws Exception {
		synStatus.setSrc(prefix);
		JSONObject jsonObject=JSONObject.fromObject(synStatus);
		MarvelsLogUtil.getInstance().info(">>>>>>sharing_platform_data_modify请求数据"+jsonObject.toString()+"mq请求开始");
		amqpTemplate.convertAndSend("sharing_platform_data_modify",jsonObject.toString());
		MarvelsLogUtil.getInstance().info(">>>>>>sharing_platform_data_modify请求数据"+jsonObject.toString()+"mq请求结束");
		
	}

	@Override
	public void synSharedDataAdd(EdcSharedDataDTO synStatus) throws Exception {
		String prefix = PropertiesUtils.getString("loanid.prefix", "application.properties");
		synStatus.setSrc(prefix);
		JSONObject jsonObject=JSONObject.fromObject(synStatus);
		MarvelsLogUtil.getInstance().info(">>>>>>sharing_platform_data_add添加数据"+jsonObject.toString()+"mq请求开始");
		amqpTemplate.convertAndSend("sharing_platform_data_add",jsonObject.toString());
		MarvelsLogUtil.getInstance().info(">>>>>>sharing_platform_data_add添加数据"+jsonObject.toString()+"mq请求结束");
		
	}

	

}
